import * as Koa from "koa";
import cors = require("kcors");
import bodyParser = require("koa-bodyparser");
import logger = require("koa-log4");

export const app = new Koa();

app.use(bodyParser());
app.use(cors());
app.use(logger.koaLogger(logger.getLogger("http"), {level: "auto"}));

// response
app.use(async (ctx) => {
    ctx.body = "hello world";
    // throw new Error("111");
});

app.on("error", (err, ctx) =>
    console.error("server error", err, ctx),
);
